package com.pz.cloud.framework.workflow.controller;

import com.alibaba.fastjson.JSONObject;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("business")
public class BusinessController {

    private RuntimeService runtimeService;

    /**
     * 获取业务数据主键
     * @param instanceId
     * @return
     */
    @RequestMapping("/findByInstanceId")
    public Result findByInstanceId(String instanceId){
        ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult();
        String id = instance.getBusinessKey();
        return  Result.OK("查询成功");
    }

    private JSONObject findById(String id){
        JSONObject result = new JSONObject();
        result.put("id",id);
        return result;
    }

}
